// https://www.acwing.com/problem/content/description/798/

#include <vector>
#include <iostream>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int m, n, t;
    cin>>m>>n>>t;
    vector<vector<int>> matrix(m, vector<int>(n));
    vector<vector<int>> pre_sum(m+1, vector<int>(n+1));
    for (int i=0; i < m; i++) {
        for (int j=0; j < n; j++) {
            cin>>matrix[i][j];
        }
    }

    pre_sum[1][1] = matrix[0][0];
    for (int i=2; i <= m; i++) {
        pre_sum[i][1] = pre_sum[i-1][1] + matrix[i-1][0];
    }
    for (int i=2; i <= n; i++) {
        pre_sum[1][i] = pre_sum[1][i-1] + matrix[0][i-1];
    }

    for (int i=2; i <= m; i++) {
        for (int j=2; j <= n; j++) {
            pre_sum[i][j] += pre_sum[i-1][j] + pre_sum[i][j-1] + matrix[i-1][j-1] - pre_sum[i-1][j-1];
        }
    }

    while (t-->0) {
        int x1, y1, x2, y2;
        cin>>x1>>y1>>x2>>y2;
        const int result = pre_sum[x2][y2] - pre_sum[x2][y1-1] - pre_sum[x1-1][y2] + pre_sum[x1-1][y1-1];
        cout<<result<<endl;
    }

    return 0;
}